﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using EnvironmentManagerSystem.BLL;
using EnvironmentManagerSystem.MODE;
using AjaxPro;

namespace EnvironmentManagerSystem.EvaluationUnitManager
{
    public partial class EUMmain : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (StfInfo.ReSession()) return; if (!IsPostBack)
            {
                RoleID.Text = Session["roleid"].ToString();
                if (RoleID.Text == "环评单位")
                {
                    SDStab.Visible = false;
                    EUMtab.Visible = true;
                }
                else
                {
                    SDStab.Visible = true;
                    EUMtab.Visible = false;
                }
                string ProjectName = Request.QueryString["ProjectName"];
                if (ProjectName != "")
                {
                    DevelopprojectbasicinfoDataCollection lst = BLL.NoticeService.GetByIDPdd(ProjectName);
                    foreach (var item in lst)
                    {
                        Label1.Text = item.ProjectName;//项目名称                        
                    }
                }
                Session["pjName"] = Label1.Text.ToString();
                Bind();
            }
        }

        #region 方法(绑定状态)(x)
        public void Bind()
        {
            try
            {
                if (Session["pjName"] != null && !Session["pjName"].ToString().Equals("") && !Session["pjName"].ToString().Equals("无"))
                {
                    DevelopprojectbasicinfoDataCollection lst = BLL.XIANGMU.GetByProjectName(Session["pjName"].ToString());
                    if (lst.Count > 0)
                    {
                        //受理状态
                        if (lst[0].xiangmushouliren != null && lst[0].xiangmushouliren != "" && lst[0].shoulituihuishanchu == 1)
                        {
                            xiangmushouliren.Text = string.Format("已受理");
                            Image1.ImageUrl = "~/images/bookmark-2.ico";
                            //受理时间 
                            xiangmushoulishijian.Text = lst[0].xiangmushoulishijian.ToString();
                        }
                        else
                        {
                            xiangmushouliren.Text = "未受理";
                            Image1.ImageUrl = "~/images/white-star.png";
                            xiangmushoulishijian.Text = "";
                        }
                        //项目分配状态
                        if (lst[0].fenpeiquerenren != null && lst[0].fenpeiquerenren != "")
                        {
                            if (XIANGMU.WhetherLeader(lst[0].fenpeiquerenren.ToString()))
                            {
                                fenpeiquerenren.Text = string.Format("已确认");
                                Image2.ImageUrl = "~/images/bookmark-2.ico";
                                //项目分配日期
                                fenpeiquerenshijian.Text = lst[0].fenpeiquerenshijian.ToString();
                                //用时几天
                                DateTime DateTime1 = Convert.ToDateTime(lst[0].xiangmushoulishijian.ToString());//起始时间
                                DateTime DateTime2 = Convert.ToDateTime(lst[0].fenpeiquerenshijian.ToString());//结束时间                                
                                string dateDiff1 = null;
                                TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
                                TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
                                TimeSpan ts3 = ts1.Subtract(ts2).Duration();
                                int ts33 = NoticeService.ProNoticeDays(lst[0].fenpeiquerenshijian.ToString(), lst[0].xiangmushoulishijian.ToString());
                                //显示时间
                                dateDiff1 = "用时" + (ts3.Days + 1 - ts33).ToString() + "天";
                                Time2.Text = dateDiff1;
                                Time2.Visible = true;
                            }
                            else
                            {
                                fenpeiquerenren.Text = string.Format("已处理");
                                Image2.ImageUrl = "~/images/white-star.png";
                                //项目分配日期
                                fenpeiquerenshijian.Text = lst[0].fenpeiquerenshijian.ToString();
                                Time2.Visible = false;
                            }
                        }
                        else
                        {
                            fenpeiquerenren.Text = "未处理";
                            Image2.ImageUrl = "~/images/white-star.png";
                            fenpeiquerenshijian.Text = "";
                            Time2.Visible = false;
                        }
                        //项目负责状态
                        if (lst[0].xiangmufuzequerenren != null && lst[0].xiangmufuzequerenren != "" && lst[0].fuzetuihuiqueren == 1)
                        {
                            if (XIANGMU.WhetherLeader(lst[0].xiangmufuzequerenren.ToString()))
                            {
                                xiangmufuzequerenren.Text = string.Format("已确认");
                                Image3.ImageUrl = "~/images/bookmark-2.ico";
                                //项目负责日期
                                xiangmufuzequerenriqi.Text = lst[0].xiangmufuzequerenriqi.ToString();
                                //用时几天
                                DateTime DateTime3 = Convert.ToDateTime(lst[0].xiangmushoulishijian.ToString());//起始时间
                                DateTime DateTime4 = Convert.ToDateTime(lst[0].xiangmufuzequerenriqi.ToString());//结束时间
                                string dateDiff2 = null;
                                TimeSpan ts4 = new TimeSpan(DateTime3.Ticks);
                                TimeSpan ts5 = new TimeSpan(DateTime4.Ticks);
                                TimeSpan ts6 = ts4.Subtract(ts5).Duration();
                                int ts66 = NoticeService.ProNoticeDays(lst[0].xiangmufuzequerenriqi.ToString(), lst[0].xiangmushoulishijian.ToString());
                                //显示时间
                                dateDiff2 = "用时" + (ts6.Days + 1 - ts66).ToString() + "天";
                                Time3.Text = dateDiff2;
                                Time3.Visible = true;
                            }
                            else
                            {
                                xiangmufuzequerenren.Text = string.Format("已处理");
                                Image3.ImageUrl = "~/images/white-star.png";
                                //项目负责日期
                                xiangmufuzequerenriqi.Text = lst[0].xiangmufuzequerenriqi.ToString();
                                Time3.Visible = false;
                            }
                        }
                        else
                        {
                            xiangmufuzequerenren.Text = "未处理";
                            Image3.ImageUrl = "~/images/white-star.png";
                            xiangmufuzequerenriqi.Text = "";
                            Time3.Visible = false;
                        }
                        //现场踏查状态
                        if (lst[0].tachaquerenren != null && lst[0].tachaquerenren != "" && lst[0].tachaquerentuihui == 1)
                        {
                            if (XIANGMU.WhetherLeader(lst[0].tachaquerenren.ToString()))
                            {
                                tachaquerenren.Text = string.Format("已确认");
                                Image4.ImageUrl = "~/images/bookmark-2.ico";
                                //现场踏查日期
                                tachaquerenriqi.Text = lst[0].tachaquerenriqi.ToString();
                                //用时几天
                                DateTime DateTime5 = Convert.ToDateTime(lst[0].xiangmushoulishijian.ToString());//起始时间
                                DateTime DateTime6 = Convert.ToDateTime(lst[0].tachaquerenriqi.ToString());//结束时间
                                string dateDiff3 = null;
                                TimeSpan ts7 = new TimeSpan(DateTime5.Ticks);
                                TimeSpan ts8 = new TimeSpan(DateTime6.Ticks);
                                TimeSpan ts9 = ts7.Subtract(ts8).Duration();
                                int ts99 = NoticeService.ProNoticeDays(lst[0].tachaquerenriqi.ToString(), lst[0].xiangmushoulishijian.ToString());
                                //显示时间
                                dateDiff3 = "用时" + (ts9.Days + 1 - ts99).ToString() + "天";
                                Time4.Text = dateDiff3;
                                Time4.Visible = true;
                            }
                            else
                            {
                                tachaquerenren.Text = string.Format("已处理");
                                Image4.ImageUrl = "~/images/white-star.png";
                                //现场踏查日期
                                tachaquerenriqi.Text = lst[0].tachaquerenriqi.ToString();
                                Time4.Visible = false;
                            }
                        }
                        else
                        {
                            tachaquerenren.Text = "未处理";
                            Image4.ImageUrl = "~/images/white-star.png";
                            tachaquerenriqi.Text = "";
                            Time4.Visible = false;
                        }
                        //专家会议状态
                        if (lst[0].zhuanjiahuiyiquerenren != null && lst[0].zhuanjiahuiyiquerenren != "")
                        {
                            if (XIANGMU.WhetherLeader(lst[0].zhuanjiahuiyiquerenren.ToString()))
                            {
                                zhuanjiahuiyiquerenren.Text = string.Format("已确认");
                                Image5.ImageUrl = "~/images/bookmark-2.ico";
                                //专家会议时间
                                zhuanjiahuiyiquerenriqi.Text = lst[0].zhuanjiahuiyiquerenriqi.ToString();
                                //用时几天
                                DateTime DateTime7 = Convert.ToDateTime(lst[0].xiangmushoulishijian.ToString());//起始时间
                                DateTime DateTime8 = Convert.ToDateTime(lst[0].zhuanjiahuiyiquerenriqi.ToString());//结束时间
                                string dateDiff4 = null;
                                TimeSpan ts10 = new TimeSpan(DateTime7.Ticks);
                                TimeSpan ts11 = new TimeSpan(DateTime8.Ticks);
                                TimeSpan ts12 = ts10.Subtract(ts11).Duration();
                                int ts1212 = NoticeService.ProNoticeDays(lst[0].zhuanjiahuiyiquerenriqi.ToString(), lst[0].xiangmushoulishijian.ToString());
                                //显示时间
                                dateDiff4 = "用时" + (ts12.Days + 1 - ts1212).ToString() + "天";
                                Time5.Text = dateDiff4;
                                Time5.Visible = true;
                            }
                            else
                            {
                                zhuanjiahuiyiquerenren.Text = string.Format("已处理");
                                Image5.ImageUrl = "~/images/white-star.png";
                                //专家会议时间
                                zhuanjiahuiyiquerenriqi.Text = lst[0].zhuanjiahuiyiquerenriqi.ToString();
                                Time5.Visible = false;
                            }
                        }
                        else
                        {
                            zhuanjiahuiyiquerenren.Text = "未处理";
                            Image5.ImageUrl = "~/images/white-star.png";
                            zhuanjiahuiyiquerenriqi.Text = "";
                            Time5.Visible = false;
                        }
                        //评估意见状态
                        if (lst[0].pingguyijianchuliren != null && lst[0].pingguyijianchuliren != "")
                        {
                            if (XIANGMU.WhetherLeader(lst[0].pingguyijianchuliren.ToString()))
                            {
                                pingguyijian.Text = string.Format("已确认");
                                Image6.ImageUrl = "~/images/bookmark-2.ico";
                                //评估意见日期
                                pingguyijianchuliriqi.Text = lst[0].pingguyijianchuliriqi.ToString();
                                //用时几天
                                DateTime DateTime9 = Convert.ToDateTime(lst[0].xiangmushoulishijian.ToString());//起始时间
                                DateTime DateTime10 = Convert.ToDateTime(lst[0].pingguyijianchuliriqi.ToString());//结束时间
                                string dateDiff5 = null;
                                TimeSpan ts13 = new TimeSpan(DateTime9.Ticks);
                                TimeSpan ts14 = new TimeSpan(DateTime10.Ticks);
                                TimeSpan ts15 = ts13.Subtract(ts14).Duration();
                                int ts1515 = NoticeService.ProNoticeDays(lst[0].pingguyijianchuliriqi.ToString(), lst[0].xiangmushoulishijian.ToString());
                                //显示时间
                                dateDiff5 = "用时" + (ts15.Days + 1 - ts1515).ToString() + "天";
                                Time6.Text = dateDiff5;
                                Time6.Visible = true;
                            }
                            else
                            {
                                pingguyijian.Text = string.Format("已处理");
                                Image6.ImageUrl = "~/images/white-star.png";
                                //评估意见日期
                                pingguyijianchuliriqi.Text = lst[0].pingguyijianchuliriqi.ToString();
                                Time6.Visible = false;
                            }
                        }
                        else
                        {
                            pingguyijian.Text = "未处理";
                            Image6.ImageUrl = "~/images/white-star.png";
                            pingguyijianchuliriqi.Text = "";
                            Time6.Visible = false;
                        }
                        //项目考评状态
                        if (lst[0].xiangmukaopingchuliren != null && lst[0].xiangmukaopingchuliren != "")
                        {
                            if (XIANGMU.WhetherLeader(lst[0].xiangmukaopingchuliren.ToString()))
                            {
                                xiangmukaopingchuliren.Text = string.Format("已确认");
                                Image7.ImageUrl = "~/images/bookmark-2.ico";
                                //项目考评日期
                                xiangmukaopingchuliriqi.Text = lst[0].xiangmukaopingchuliriqi.ToString();
                                //用时几天
                                DateTime DateTime11 = Convert.ToDateTime(lst[0].xiangmushoulishijian.ToString());//起始时间
                                DateTime DateTime12 = Convert.ToDateTime(lst[0].xiangmukaopingchuliriqi.ToString());//结束时间
                                string dateDiff6 = null;
                                TimeSpan ts16 = new TimeSpan(DateTime11.Ticks);
                                TimeSpan ts17 = new TimeSpan(DateTime12.Ticks);
                                TimeSpan ts18 = ts16.Subtract(ts17).Duration();
                                int ts1818 = NoticeService.ProNoticeDays(lst[0].xiangmukaopingchuliriqi.ToString(), lst[0].xiangmushoulishijian.ToString());
                                //显示时间
                                dateDiff6 = "用时" + (ts18.Days + 1 - ts1818).ToString() + "天";
                                Time7.Text = dateDiff6;
                                Time7.Visible = true;
                            }
                            else
                            {
                                xiangmukaopingchuliren.Text = string.Format("已处理");
                                Image7.ImageUrl = "~/images/white-star.png";
                                //项目考评日期
                                xiangmukaopingchuliriqi.Text = lst[0].xiangmukaopingchuliriqi.ToString();
                                Time7.Visible = false;
                            }
                        }
                        else
                        {
                            xiangmukaopingchuliren.Text = "未处理";
                            Image7.ImageUrl = "~/images/white-star.png";
                            xiangmukaopingchuliriqi.Text = "";
                            Time7.Visible = false;
                        }
                        //汇总上报状态
                        //if (lst[0].reportpeople != null && lst[0].reportpeople != "" && lst[0].reportstate != 3)
                        //lst[0].ReportingTrace != null && 
                        if(lst[0].ReportingTrace != "" && lst[0].tachaquerentuihui !=2)
                        {
                            if (XIANGMU.WhetherLeader(lst[0].reportpeople.ToString()))
                            {
                                reportstate.Text = string.Format("已确认");
                                Image8.ImageUrl = "~/images/bookmark-2.ico";
                                //汇总上报日期
                                reportdate.Text = lst[0].reportdate.ToString();
                                //用时几天
                                DateTime DateTime19 = Convert.ToDateTime(lst[0].xiangmushoulishijian.ToString());//起始时间
                                DateTime DateTime20 = Convert.ToDateTime(lst[0].reportdate.ToString());//结束时间
                                string dateDiff7 = null;
                                TimeSpan ts19 = new TimeSpan(DateTime19.Ticks);
                                TimeSpan ts20 = new TimeSpan(DateTime20.Ticks);
                                TimeSpan ts21 = ts19.Subtract(ts20).Duration();
                                int ts2121 = NoticeService.ProNoticeDays(lst[0].reportdate.ToString(), lst[0].xiangmushoulishijian.ToString());
                                //显示时间
                                dateDiff7 = "用时" + (ts21.Days + 1 - ts2121).ToString() + "天";
                                Time8.Text = dateDiff7;
                                Time8.Visible = true;
                            }
                            else
                            {
                                reportstate.Text = string.Format("已处理");
                                Image8.ImageUrl = "~/images/white-star.png";
                                //汇总上报日期
                                reportdate.Text = lst[0].reportdate.ToString();
                                Time8.Visible = false;
                            }
                        }
                        else
                        {
                            reportstate.Text = "未处理";
                            Image8.ImageUrl = "~/images/white-star.png";
                            reportdate.Text = "";
                            Time8.Visible = false;
                        }
                    }
                }
            }
            catch
            { }
        }
        #endregion
    }
}
